import sysConfig from '@/config/index'
import user from '../api/user'
/**
 * 工具类
 */
const tool = {
    selectProvince(directflag) {
        return undefined
    }
}

// localStorage
tool.data = {
    set(table, settings) {
        const _set = JSON.stringify(settings)
        return localStorage.setItem(table, _set)
    },
    get(table) {
        let data = localStorage.getItem(table)
        try {
            data = JSON.parse(data)
        }
        catch (err) {
            return null
        }
        return data
    },
    remove(table) {
        return localStorage.removeItem(table)
    },

    clear() {
        return localStorage.clear()
    }
}

tool.out = {
    outLogin(table) {
        user.outLogin().then(item=>{
            localStorage.removeItem(sysConfig.TOKEN_NAME)
            tool.data.remove('tokenInfo')
        })
    }
}

export default tool